<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title><s:text name="title" /></title>
	</head>
	<body>
		<p>
			<s:text name="welcome" />
			<s:if test="#session.user==null">
				<b> <s:text name="visitor" /> <a href="../login/login.jsp"><s:text
							name="login" /> </a> </b>
			</s:if>
			<s:else>
				<b> <s:if test="#session.user.type==1">
						<s:text name="member" />
					</s:if> <s:elseif test="#session.user.type==2">
						<s:text name="manager" />
					</s:elseif> <s:elseif test="#session.user.type==3">
						<s:text name="administrator" />
					</s:elseif> <s:property value="#session.user.realName" /> </b>
				<a href="../login/userInfo.action"><s:text name="userInfo" /> </a>
				<a href="../login/logOut.action"><s:text name="logOut" /> </a>
			</s:else>
		</p>
		<s:actionerror />
		<s:fielderror></s:fielderror>
		
		<!-- 
		<s:if test="#session.user==null||#session.user.type<=2">
			<p>
				<B><s:text name="flight.select"></s:text> </B>
			</p>
			<table>
				<tr>
					<s:form action="queryFlightList" namespace="/mainService">
						<td>
							<s:text name='flight.name' />
						</td>
						<td>
							<s:textfield name="flight.name" />
						</td>
						<td>
							<s:text name='flight.start' />
						</td>
						<td>
							<s:textfield name="flight.start" />
						</td>
						<td>
							<s:text name='flight.end' />
						</td>
						<td>
							<s:textfield name="flight.end"></s:textfield>
						</td>
						<td>
							<s:submit key="select"></s:submit>
							<input type="button"
								onclick="location.href='/booking/mainService/main.action';"
								value="<s:text name='selectAll'/>">
						</td>
					</s:form>
				</tr>
			</table>
			<p>
				<B><s:text name="flightList"></s:text> </B>
				<s:if test="#session.user.type==2">
					<a href="./flightInfo.jsp"><s:text name="insert" /> </a>
					<input type="button" value="<s:text name='delete'/>"
						onclick="document.getElementById('deleteFlightsForm').submit();">
				</s:if>

			</p>
			<s:if test="flightList.size()>0">
			<table cellspacing="1" cellpadding="1" border="1">
				<thead>
					<tr>
						<s:if test="#session.user.type==2">
							<th>
								<input type="checkbox" name="all" id="all"
									onclick="selectAll('all','id');">
							</th>
						</s:if>
						<th align="center">
							<s:text name='flight.name' />
						</th>
						<th align="center">
							<s:text name='flight.start' />
						</th>
						<th align="center">
							<s:text name='flight.end' />
						</th>
						<th align="center">
							<s:text name='flight.description' />
						</th>
						<th align="center">
							<s:text name='flight.price' />
						</th>
						<th align="center">
							<s:text name='flight.totalNum' />
						</th>
						<th align="center">
							<s:text name='flight.leftNum' />
						</th>
						<s:if test="#session.user==null||#session.user.type==1">
							<th>
								<s:text name="flight.booking" />
							</th>
						</s:if>
						<s:elseif test="#session.user.type==2">
							<th>
								<s:text name="modify" />
							</th>
							<th>
								<s:text name="userTicketManage" />
							</th>
							<th>
								<s:text name="delete" />
							</th>
						</s:elseif>
					</tr>
				</thead>
				<tbody>
					<s:form action="deleteFlights" namespace="/mainService"
						id="deleteFlightsForm">
						<s:iterator value="flightList" status="flight">
							<tr>
								<s:if test="#session.user.type==2">
									<td>
										<s:checkbox name="id" value="false" fieldValue="%{id}"></s:checkbox>
									</td>
								</s:if>
								<td align="left">
									<s:property value="name" />
								</td>
								<td align="left">
									<s:property value="start" />
								</td>
								<td align="left">
									<s:property value="end" />
								</td>
								<td align="left">
									<s:property value="description" />
								</td>
								<td align="right">
									<s:property value="price" />
								</td>
								<td align="right">
									<s:property value="totalNum" />
								</td>
								<td align="right">
									<s:property value="leftNum" />
								</td>
								<s:if test="#session.user==null||#session.user.type==1">
									<td>
										<s:if test="leftNum>0">
											<a href="./bookingQuery.action?id=<s:property value='id'/>"><s:text
													name="flight.booking" /> </a>
										</s:if>

									</td>
								</s:if>
								<s:elseif test="#session.user.type==2">
									<td>
										<a href="./queryFlight.action?id=<s:property value='id'/>"><s:text
												name="modify" /> </a>
									</td>
									<td>
										<a
											href="./queryUserTicketList.action?id=<s:property value='id'/>"><s:text
												name="userTicketManage" /> </a>
									</td>
									<td>
										<a href="./deleteFlight.action?id=<s:property value='id'/>"><s:text
												name="delete" /> </a>
									</td>
								</s:elseif>
							</tr>
						</s:iterator>
					</s:form>
				</tbody>
			</table>
			</s:if>
			<s:else>
				<s:text name="noFlight"></s:text>
			</s:else>
		</s:if>
		<s:if test="#session.user.type==1&&userTicketList.size()>0">
			<p></p>
			<b><s:text name="userTicketInfo" /> </b>
			<p></p>
			<s:if test="userTicketList.size()>0">
			<table cellspacing="1" cellpadding="1" border="1">
				<thead>
					<tr>
						<th>
							<s:text name="flight.name" />
						</th>
						<th>
							<s:text name="flight.price" />
						</th>
						<th>
							<s:text name="userTicket.num" />
						</th>
						<th>
							<s:text name="userTicket.totalPrice" />
						</th>
					</tr>
					<s:iterator value="userTicketList" status="userTicket">
						<tr>
							<td>
								<s:property value="flightName" />
							</td>
							<td>
								<s:property value="price" />
							</td>
							<td>
								<s:property value="num" />
							</td>
							<td>
								<s:property value="totalPrice" />
							</td>
						</tr>
					</s:iterator>
				</thead>
			</table>
			</s:if>
			<s:else>
				<s:text name="noUserTicket"></s:text>
			</s:else>
		</s:if>
		-->
		
		<s:if test="#session.user.type==3">
			<p>
				<B><s:text name="userInfo"></s:text> </B>
				<a href="../mainService/userInfo.jsp"><s:text name="insert" /> </a>
				<input type="button" value="<s:text name='delete'/>"
					onclick="document.getElementById('deleteUsersForm').submit();">
			</p>
			<s:if test="userList.size()>0">
				<table cellspacing="1" cellpadding="1" border="1">
					<tr>
						<td><input type="checkbox" name="all" id="all"
									onclick="selectAll('all','id');">
							<s:text name="selectAll"></s:text>
						</td>
						<th>
							<s:text name="userName"></s:text>
						</th>
						<th>
							<s:text name="realName"></s:text>
						</th>
						<th>
							<s:text name="idCard"></s:text>
						</th>
						<th>
							<s:text name="type"></s:text>
						</th>
						<th>
							<s:text name="modify" />
						</th>
						<th>
							<s:text name="delete" />
						</th>
					</tr>
					<tbody>
						<s:form action="deleteUsers" namespace="/mainService" id="deleteUsersForm">
							<s:iterator value="userList">
								<tr>
									<td>
										<s:checkbox name="id" value="false" fieldValue="%{id}"></s:checkbox>
									</td>
									<td>
										<s:property value="userName"/>
									</td>
									<td>
										<s:property value="realName"/>
									</td>
									<td>
										<s:property value="idCard"/>
									</td>
									<td>
										<s:if test="type==1">
											<s:text name="member" />
										</s:if> <s:elseif test="type==2">
											<s:text name="manager" />
										</s:elseif> <s:elseif test="type==3">
											<s:text name="administrator" />
										</s:elseif>
									</td>
									<td>
										<a href="./queryUser.action?id=<s:property value='id'/>"><s:text
												name="modify" /> </a>
									</td>
									<td>
										<a href="./deleteUser.action?id=<s:property value='id'/>"><s:text
												name="delete" /> </a>
									</td>
								</tr>
							</s:iterator>
						</s:form>
					</tbody>
				</table>
			</s:if>
			<s:else>
				<s:text name="noUser"></s:text>
			</s:else>
		</s:if>
		<script>
	function selectAll(father,child) {
		var o = document.getElementsByName(child);
		var flag = document.getElementById(father).checked;
		for (i = 0; i < o.length; i++) {
			o[i].checked = flag;
		}
	}
</script>
	</body>
</html>
